// 引入Service和请求头ServiceName
import { Service, ServiceName } from '@/network/http.js'
import store from '@/store/index.js' // 引入store

const api = {
    /**
        * 获取主列表数据
        */
    gettabledata (params) {
        return Service.get(
            `/${ServiceName}/api/external/mtcargo/getcargolist`, { params }
        )
    },
    /**
      * 修改货种数据
      */
    updatedata (params) {
        store.commit('changeStatus', true)
        return Service.put(
            `/${ServiceName}/api/external/mtcargo/updatecargo`, params
        )
    },
    /**
     * 修改货名数据
     */
    updatagoods (params) {
        store.commit('changeStatus', true)
        return Service.get(
            `/${ServiceName}/api/external/mtcargo/querycargoinfobyid?id=${params}`
        )
    },
    /**
     * 删除货名数据
     */
    deletegoods (params) {
        return Service.delete(
            `/${ServiceName}/api/external/mtcargo/deletebyid?id=${params}`
        )
    },
    /**
     * 新增货名数据
     */
    addgoods (params) {
        store.commit('changeStatus', true)
        return Service.post(
            `/${ServiceName}/api/external/mtcargo/add`,  params 
        )
    },
    
    /**
     * 新增货种数据
     */
     addcargo (params) {
        store.commit('changeStatus', true)
        return Service.post(
            `/${ServiceName}/api/external/mtcargo/addcargo`,  params 
        )
    },
}

export default api
